package com.src.computec.logsgestion.base.helper;

import com.src.computec.logsgestion.base.constantes.ConstantesGenerales;
import com.src.computec.logsgestion.base.dao.BaseFactoryDAO;
import com.src.computec.radar.base.util.Logger;



public abstract class BaseHelper {

    private BaseFactoryDAO factoryDAO;

    /** Creates a new instance of BaseService */
    protected BaseHelper() {
        this.initializeFactoryDAO();
    }

    private void initializeFactoryDAO() {
        String factoryDAOClassName = ConstantesGenerales.getInstance().FACTORYDAO_CLASSNAME;
        try {
            this.setFactoryDAO( (BaseFactoryDAO)Class.forName(factoryDAOClassName).newInstance() );
        }
        catch(InstantiationException e) {
            Logger.getInstance().log("Error en "+this.getClass().getName()+" al inicializar el FactoryDAO.",e);
        }
        catch (ClassNotFoundException e) {
            Logger.getInstance().log("Error en "+this.getClass().getName()+" al inicializar el FactoryDAO.",e);
        }
        catch(IllegalAccessException e) {
            Logger.getInstance().log("Error en "+this.getClass().getName()+" al inicializar el FactoryDAO.",e);
        }
    }

    public BaseFactoryDAO getFactoryDAO() {
        return factoryDAO;
    }

    public void setFactoryDAO(BaseFactoryDAO factoryDAO) {
        this.factoryDAO = factoryDAO;
    }
}